if(!require(showtext)){install.packages("showtext")}
if(!require(ggplot2)){install.packages("ggplot2")}
if(!require(magick)){install.packages("magick")}
if(!require(knitr)){install.packages("knitr")}
# Activar showtext
showtext_auto()
# Agregar la fuente Oswald desde Google Fonts
font_add_google(name = "Oswald", family = "Oswald")
library(ggplot2)
# Crear los datos
data <- data.frame(
xstart = c(0, 0.2, 0.4, 0.6, 0.8),
xend = c(0.2, 0.4, 0.6, 0.8, 1),
ystart = rep(0, 5),
yend = rep(1, 5),
labels = c("Solo publicación", "Código", "Código y datos",
"Código y datos\nejecutables", "Replicación\ncompleta")
)
# Colores personalizados desde oscuro a claro
#colors <- c("#555555", "#777777", "#999999", "#bbbbbb", "#dddddd")
colors <- c("#4D4D4D", "#B03A2E", "#E74C3C", "#F1948A", "#FADBD8")
# Crear el gráfico
ggplot() +
# Dibujar las áreas
geom_rect(data = data, aes(xmin = xstart, xmax = xend, ymin = ystart, ymax = yend, fill = labels), color = NA) +
scale_fill_manual(values = colors) +
# Agregar las etiquetas dentro de las áreas
geom_text(data = data, aes(x = (xstart + xend) / 2, y = 0.5, label = labels), size = 6, family = "Oswald", color = "black") +
# Agregar flecha de reproducibilidad
annotate("segment", x = 0, xend = 1, y = -0.1, yend = -0.1, arrow = arrow(type = "closed", ends = "both"), color = "gray") +
annotate("text", x = 0.05, y = -0.15, label = "No\nreproducible", size = 5, hjust = 0.5, color = "#555555") +
annotate("text", x = .95, y = -0.15, label = "Estándar\nde oro", size = 5, hjust = 0.5, color = "#555555") +
# Ajustar límites y tema
scale_x_continuous(limits = c(0, 1), expand = c(0, 0)) +
scale_y_continuous(limits = c(-0.2, 1), expand = c(0, 0)) +
theme_void() +
theme(
legend.position = "none",
text = element_text(family = "Oswald"),
plot.background = element_rect(fill = "#ffffff", color = NA)
)